
//
//  CourseNavView.m
//  ShowYork
//
//  Created by hxh on 2020/8/28.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "LessonCenterNavView.h"

@interface LessonCenterNavView ()
@property (nonatomic,strong)UIView *searchView;
@property (nonatomic,strong)UILabel *searchLb;
@property (nonatomic,strong)UIImageView *searchImgView;
@property (nonatomic,strong)UIImageView *checkImgView;
@property (nonatomic,strong)UIButton *searchBtn;
@property (nonatomic,strong)UIButton *backBtn;
@property (nonatomic,strong)UIImageView *backImgView;
@end

@implementation LessonCenterNavView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
    
    self.backgroundColor = RGBA(248, 248, 248, 1);
    
    self.searchView = [[UIView alloc]init];
    self.searchView.layer.cornerRadius = 15;
    self.searchView.layer.borderColor = [RPAppManager themColor].CGColor;
    self.searchView.layer.borderWidth = 1;
    self.searchView.backgroundColor = RGBA(243, 243, 243, 1);
    [self addSubview:self.searchView];

    self.searchLb = [[UILabel alloc]init];
    self.searchLb.text = @"";
    self.searchLb.textColor = RGBA(204, 204, 204, 1);
    self.searchLb.font = font(14);
    [self addSubview:self.searchLb];
    
    self.backImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"common_back_tag"]];
    [self addSubview:self.backImgView];
    
    self.backBtn = [[UIButton alloc]init];
    [self.backBtn addTarget:self action:@selector(backMethod) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.backBtn];
    
    
    
    self.searchImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"course_search"]];
    [self addSubview:self.searchImgView];
    
 
    
    self.searchBtn = [[UIButton alloc]init];
    [self.searchBtn addTarget:self action:@selector(searchMethod) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.searchBtn];
    
    
    [self.backImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(20);
    }];
    
    [self.backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.left.equalTo(self);
        make.right.equalTo(self.searchView.mas_left).offset(-8);
    }];

    [self.searchView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.centerY.equalTo(self);
        make.right.equalTo(self).offset(-16);
        make.left.equalTo(self).offset(54);
    }];
       
    [self.searchImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.equalTo(self.searchView).offset(8);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    
    [self.searchLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.searchView);
        make.left.equalTo(self.searchImgView.mas_right).offset(3);
        make.right.equalTo(self.searchView).offset(-18);
    }];
    
    [self.searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.searchView);
    }];
}

- (void)backMethod{
    if (self.back) {
        self.back();
    }
}

- (void)searchMethod{
    if (self.done) {
        self.done();
    }
}
- (void)setNavTitle:(NSString *)navTitle{
    self.searchLb.text = navTitle;
}

@end
